<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group(['namespace'=>'Api\V1'],function (){


    Route::post('login','LoginController@index');
});

                                    //config 下的 auth 下的 api 验证 此处为 接口账号的 token 验证
Route::group(['namespace'=>'Api\V1','middleware'=>'auth:api'],function (){

    Route::get('sendSms','LoginController@sendSms');
    Route::post('generateToken','TokenController@generateToken');

});

//token 也可以像 密码加盐 一样的md5 加密 替代
/*
 * $params="接收值"
 * $salt="2008a"; md5($salt.$params)    通过盐的加密 生成的码 就是唯一的
 *
 *首次进行加密,当前端每次登录时进行对照
 */
Route::group(['namespace'=>'Api\V1','middleware'=>['auth:api','checkJwt']],function (){

    Route::post('v1/user/userinfo','UserController@userinfoFun');
    Route::get('v1/user/userinfo','UserController@getUserInfo'); //获取用户信息


    Route::post('v1/file/ossUpload','FileController@ossUpload');

    Route::get('v1/notices','NoticesController@getNoticesList');
    Route::get('v1/news','ArticleController@getNewList');

    Route::post('v1/news/{news}','ArticleController@getNewsDetail');
});
